home *** CD-ROM | disk | FTP | other *** search
/ MacFormat UK 186 / MF_UK_186_1.iso / pc / DiscContents / In the mag / Widgets / FlopCruncher 1.3 / FlopCruncher / FlopCruncher.wdgt / FlopCruncher.js < prev    next >
Encoding:
JavaScript  |  2007-07-16  |  51.1 KB  |  1,198 lines

  1. // FlopCruncher 1.3 by "Maniac": FlopTech Engineering
  2. var playercount=10, holecount=20, cardcount=25, rank=0, suit=1, deals, seat, sName, sMode=false, count=0, times=0, theme="felt", thInd=0, thCnt=5;
  3. var newsAlert=false, newsDate="0", newsStat="normal", newsURL="http://www.floptech.com/news/news.html";
  4. var handDate="0", handId=100, hPrev=0, request, today, ftNid="0", ftHid="0", runMode, purch=false, fInd=0, fItm=rank, fPrv=0, fourColor=false;
  5. var clbCol='black', diaCol='darkred', clbImg='images/front/clubblack.png', diaImg='images/front/diamondred.png', tcb, tcs;
  6. var foc=true, preflop=0, flop=1, turn=2, river=3, never=4, street=never, prevStr=never;
  7. var pMode=false, btnImg="button1", error, mt, fi, sMsg, fadeStats=true, npi=Math.PI;
  8. var oi,oip,oif,oit,oir,hsh,hsg,dpb,dfb,dtb,drb,dpbo,dfbo,dtbo,drbo,dpbdo,dfbdo,dtbdo,drbdo,dpbd,dfbd,dtbd,drbd;
  9. var A={dur:0, st:0, to:1.0, now:1.0, from:0.0, first:null, tmr:null};
  10. HC=new Array(cardcount);    CB=new Array(cardcount);    SI=new Array(cardcount);    RMT=new Array(cardcount);
  11. SMT=new Array(cardcount);    RM=new Array(cardcount);    SM=new Array(cardcount);    RT=new Array(playercount);
  12. TC=new Array(thCnt);        FS=new Array(playercount);    BC=new Array(cardcount);    BS=new Array(cardcount);
  13. DC=new Array(cardcount);    HT=new Array(4); SS=new Array(4);    SH=new Array(playercount);    DB=new Array(4);
  14.  
  15. function setup()
  16. {
  17.     var d=document; oi=outlineBoardCardsImage;
  18.     var gDoneButton=new AppleGlassButton(d.getElementById("doneButton"),"done",hidePrefs);
  19.     var gInfoButton=new AppleInfoButton(d.getElementById("infoButton"),d.getElementById("front"),"white","white",showPrefs);
  20.     gInfoButton.setStyle("white","white");
  21.     mt=d.getElementById('messageText');
  22.     var n=cardcount-1, nv=never;
  23.     do{HC[n]=new Array(2);BC[n]=new Array(2);DC[n]=new Array(2);}while(n--);
  24.     var r=rank, s=suit; n=cardcount-1;
  25.     do{    CB[n]=d["cardBackImage"+n]; SI[n]=d["popupSuitMenuImage"+n];
  26.         RMT[n]=d.getElementById("popupRankMenuText"+n); SMT[n]=d.getElementById("popupSuitMenuText"+n);
  27.         RM[n]=d.getElementById("popupRankMenu"+n); SM[n]=d.getElementById("popupSuitMenu"+n);
  28.         DC[n][r]=DC[n][s]=BC[n][r]=BC[n][s]='X'; BS[n]=nv;
  29.     }while(n--);
  30.     n=playercount-1;
  31.     do{RT[n]=d.getElementById("resultText"+n);FS[n]=nv;SH[n]=d["shadowHoleImage"+n];}while(n--);
  32.     tcb='Images/themes/felt/cardback.png'; tcs='Images/themes/felt/cardbackshad.png';
  33.     reset(2); setToolTips(); deals="1"; seat='X';
  34.     var w=widget;
  35.     if (window.widget&&(!w.preferenceForKey("news update id"))){w.setPreferenceForKey(ftNid, "news update id");}
  36.     n=thCnt-1; do{TC[n]=new Array(2);}while(n--);
  37.     TC[0][0]="#22dd22"; TC[0][1]="#003300"; TC[1][0]="#cc3333"; TC[1][1]="#330000"; TC[2][0]="#bbbbdd"; TC[2][1]="#000033"; TC[3][0]="#cccccc"; TC[3][1]="#222222"; TC[4][0]="#eeee00"; TC[4][1]="#666600";
  38.      themeToolTips(TC[0][0], TC[0][1]); kFoc(true); window.onfocus=focused; window.onblur=blurred; enableMoveTen(); storeBundledHands();
  39.     SS[preflop]="preflop"; SS[flop]="flop"; SS[turn]="turn"; SS[river]="river"; prevStr=street;
  40.     mt.innerHTML="Welcome to FlopCruncher!<br>Choose cards, then click preflop, flop, turn, and river buttons for odds.";
  41.     button1.src=button2.src=button3.src=button8.src=button9.src=button0.src='Images/front/nobutton.png';
  42.     oi.src=oip="Images/front/outlinepreflop.png";oif="Images/themes/felt/outlineflop.png";oit="Images/themes/felt/outlineturn.png";oir="Images/themes/felt/outlineriver.png";
  43.     SH[0].src=hsg="Images/themes/felt/holeglow.png"; hsh="Images/front/holeshadow.png";
  44.     DB[0]=d["dealPreFlopButton"];DB[1]=d["dealFlopButton"];DB[2]=d["dealTurnButton"];DB[3]=d["dealRiverButton"];
  45.     dpb="Images/themes/felt/dealpreflop.png";dpbo="Images/themes/felt/dealpreflopover.png";dpbdo="Images/themes/felt/dealpreflopdownover.png";dpbd="Images/themes/felt/dealpreflopdown.png";
  46.     dfb="Images/themes/felt/dealflop.png";dfbo="Images/themes/felt/dealflopover.png";dfbdo="Images/themes/felt/dealflopdownover.png";dfbd="Images/themes/felt/dealflopdown.png";
  47.     dtb="Images/themes/felt/dealturn.png";dtbo="Images/themes/felt/dealturnover.png";dtbdo="Images/themes/felt/dealturndownover.png";dtbd="Images/themes/felt/dealturndown.png";
  48.     drb="Images/themes/felt/dealriver.png";drbo="Images/themes/felt/dealriverover.png";drbdo="Images/themes/felt/dealriverdownover.png";drbd="Images/themes/felt/dealriverdown.png";
  49.     fi=frontImg; fi.src='Images/themes/felt/front.png'; 
  50. }
  51.  
  52. function setToolTips()
  53. {
  54.     var r,s,m,l,n,sn=10,h=1,d=document;
  55.     var h1='header=[<style="vertical-align:middle; z-index:25; color:#bbbbbb;">Seat ', h2='] body=[Select the ', h3=' of the hole card here. "Wild" means that any ', h4=' is OK.] fixedrelx=', hL='[20]  fixedrely=[0] delay=[2000]', hR='[-152] fixedrely=[0] delay=[2000]';
  56.     n=holecount-1;
  57.     do{    r=RM[n];s=SM[n]; r.title=h1+sn+' Hole Card Rank'+h2+'rank'+h3+'rank'+h4; s.title=h1+sn+' Hole Card Suit'+h2+'suit'+h3+'suit'+h4;
  58.         if (n<10) {s.title+=hL; r.title+=hL;}
  59.         else {s.title+=hR; r.title+=hR;}    
  60.         if (h-- == 0){sn--; h=1;}
  61.     }while(n--);
  62.     h1='header=[<style="vertical-align:middle; z-index:25; color:#bbbbbb;">'; h2=' ] body=[Select the '; h3=' card here. "Wild" means that any '; h4=' is OK.] fixedrelx=[10] fixedrely=[0] delay=[2000]';
  63.     RM[20].title=RM[21].title=RM[22].title=h1+'Flop Card Rank'+h2+'rank of the flop'+h3+'rank'+h4;
  64.     SM[20].title=SM[21].title=SM[22].title=h1+'Flop Card Suit'+h2+'suit of the flop'+h3+'suit'+h4;
  65.     h4=' is OK.] fixedrelx=[-152] fixedrely=[0] delay=[2000]';
  66.     RM[23].title=h1+'Turn Card Rank'+h2+'rank of the turn'+h3+'rank'+h4; SM[23].title=h1+'Turn Card Suit'+h2+'suit of the turn'+h3+'suit'+h4;
  67.     RM[24].title=h1+'River Card Rank'+h2+'rank of the river'+h3+'rank'+h4; SM[24].title=h1+'River Card Suit'+h2+'suit of the river'+h3+'suit'+h4;
  68.     d.resetHandsButton.title=h1+'Reset Hands] body=[Click to fold all hole cards and start over.] fixedrelx=[45] fixedrely=[8] delay=[2000]';
  69.     d.resetBoardButton.title=h1+'Reset Board] body=[Click to set all board cards to "wild" (any rank and any suit.)] fixedrelx=[-154] fixedrely=[8] delay=[2000]';
  70.     d.dealPreFlopButton.title=h1+'Preflop Odds] body=[Click to calculate odds of winning before the board cards are dealt.] fixedrelx=[-11] fixedrely=[-65] delay=[2000]';
  71.     d.dealFlopButton.title=h1+'Flop Odds] body=[Click to calculate odds of winning after the flop cards are dealt.] fixedrelx=[-20] fixedrely=[-65] delay=[2000]';
  72.     d.dealTurnButton.title=h1+'Turn Odds] body=[Click to calculate odds of winning after the turn card is dealt.] fixedrelx=[-50] fixedrely=[-65] delay=[2000]';
  73.     d.dealRiverButton.title=h1+'River Odds] body=[Click to calculate odds of winning after all the board cards are dealt.] fixedrelx=[-90] fixedrely=[-65] delay=[2000]';
  74.     d.newsButtonImage.title=h1+'News Link] body=[Click to open your browser to the FlopTech news page.] fixedabsx=[62] fixedabsy=[18] delay=[2000]';
  75.     d.floptechImage.title=h1+'FlopTech Home Link] body=[Click to open your browser to the FlopTech home page.] fixedabsx=[66] fixedabsy=[58] delay=[2000]';
  76.     d.helpButtonImage.title=h1+'Help Link] body=[Click to open your browser to the FlopCruncher Users Guide page.] fixedabsx=[67] fixedabsy=[18] delay=[2000]';
  77.     d.getElementById("popupMessageModeMenu").title=h1+'Text Option] body=[Select poker quotes or hand statistics for any occupied seat.] fixedabsx=[88] fixedabsy=[88] delay=[2000]';
  78.     d.getElementById("popupDealCountMenu").title=h1+'Deal Count Option] body=[Select fewer deals for speed, more deals for accuracy.] fixedabsx=[88] fixedabsy=[118] delay=[2000]';
  79.     d.getElementById("popupThemeMenu").title=h1+'Theme Option] body=[Select a background image and card back color.] fixedabsx=[88] fixedabsy=[148] delay=[2000]';
  80.     d.getElementById("fourColorCheck").title=h1+'Suit Color Option] body=[Check for black, red, green, and blue suits.] fixedabsx=[111] fixedabsy=[148] delay=[2000]';
  81.     d.getElementById("popupPlayMenu").title=h1+'Hand Playback] body=[Set up a hand for playback.] fixedabsx=[88] fixedabsy=[178] delay=[2000]';
  82.     d.getElementById("newsAlertCheck").title=h1+'News Alert Option] body=[Check to make FlopCruncher look for FlopTech news updates once every day.] fixedabsx=[148] fixedabsy=[175] delay=[2000]';
  83.     d.getElementById("tooltipsCheck").title=h1+'Tooltips Option] body=[Check to show info on controls when you hold the cursor over them.] fixedabsx=[71] fixedabsy=[175] delay=[2000]';
  84.     d.purchaseButtonImage.title=h1+'Purchase / Feedback Button] body=[Click to purchase FlopCruncher or to send feedback to FlopTech.] fixedabsx=[148] fixedabsy=[165] delay=[2000]';
  85. }
  86.  
  87. function showPrefs()
  88. {
  89.     if (window.widget) widget.prepareForTransition("ToBack");
  90.     document.getElementById("front").style.display="none"; document.getElementById("back").style.display="block";
  91.     if (window.widget) setTimeout('widget.performTransition();',0);
  92.     if (newsAlert) checkForNewsUpdate();
  93.     if (PokerPlugin) runMode=PokerPlugin.getResult('mode');
  94.     if (runMode=='r') document.purchaseButtonImage.src='Images/back/pb_feedback.png';
  95.     else if (runMode=='p') document.purchaseButtonImage.src='Images/back/pb_register.png';
  96.     else document.purchaseButtonImage.src='Images/back/pb_purchase.png';
  97.     themeToolTips(TC[3][0], TC[3][1]); purch=false;
  98. }
  99.  
  100. function hidePrefs()
  101. {
  102.     if (window.widget) widget.prepareForTransition("ToFront");
  103.     document.getElementById("back").style.display="none"; document.getElementById("front").style.display="block";
  104.     themeToolTips(TC[thInd][0], TC[thInd][1]);
  105.     if (purch && PokerPlugin)
  106.     {
  107.         runMode=PokerPlugin.getResult('mode');
  108.         if (runMode=='r'){mt.innerHTML="<br>Thank you for<br>purchasing<br>FlopCruncher!"; times=0;}
  109.     }
  110.     if (window.widget) setTimeout('widget.performTransition();',0);
  111.     kFoc(false);
  112. }
  113.  
  114. function checkForNewsUpdate()
  115. {
  116.     now=new Date(); today=now.getDate();
  117.     if (newsDate!=today)
  118.     {
  119.         request=new XMLHttpRequest();
  120.         request.onreadystatechange=handleHttpNewsReq;
  121.         request.open("GET","http://www.floptech.com/misc/update.txt",false);
  122.         request.send(null);
  123.     }
  124. }
  125.  
  126. function handleHttpNewsReq()
  127. {
  128.     newsStat="normal";
  129.     if (request.readyState==4 && request.status==200)    // request has completed and status is "OK"
  130.     {
  131.         newsDate=today;
  132.         var result=request.responseText; 
  133.         update=result.split(","); ftNid=update[0];
  134.         if (window.widget)
  135.         {
  136.             var curid=widget.preferenceForKey("news update id");
  137.             if (!curid || curid.length==0)curid=0;
  138.             if (curid != ftNid){newsStat="alert"; newsURL=update[1];}
  139.         }
  140.     }
  141. }
  142.  
  143. function storeBundledHands()
  144. {
  145.     if (window.widget)
  146.     {
  147.         var w=widget;
  148.         if (!w.preferenceForKey("101"))w.setPreferenceForKey("101;Brunson vs. Alto, 1976;Doyle Brunson vs. Jesse Alto<br>(1976 WSOP Championship Event);2;Brunson;2;4;0S2S;Alto;9;4;ASJH;0HAHJS2C0D;x;Preflop: It's heads-up and Brunson has the chip lead. Alto raises small, Brunson calls.;Flop: Alto hits top two and makes a pot size bet.  Brunson moves in with bottom pair no kicker, Alto calls.;Turn: Brunson makes bottom two pair, and now has only four outs.;River: A miracle ten gives Brunson his first WSOP Cham- pionship and the $220K winner-take-all prize.", "101");
  149.         if (!w.preferenceForKey("102"))w.setPreferenceForKey("102;Brunson vs. Berland, 1977;Doyle Brunson vs. \"Bones\" Berland<br>(1977 WSOP Championship Event);9;Brunson;2;4;0S2H;Berland;9;4;8H5C;0D8S5H2C0C;x;Preflop: It's down to heads-up play, and Brunson has a 4:1 chip lead. They limp in with rags.;Flop: Berland makes two pair, Brunson makes top pair, both players check.;Turn: Brunson makes top and bottom pair, Berland moves in, Brunson calls.;River: Brunson wins the WSOP Cham- pionship and $340k. Back to back wins with 10-2 for tens full of deuces.", "102");
  150.         if (!w.preferenceForKey("103"))w.setPreferenceForKey("103;Chan vs. Seidel, 1988;Johnny Chan vs. Erik Seidel<br>(1988 WSOP Championship);2;Chan;2;4;JC9C;Seidel;9;4;QC7S;QS8D0H2S6D;x;Preflop: Heads-up, Chan limps in on the button and Seidel checks the big blind.;Flop: Seidel check-raises Chan to 90K, Chan hollywoods and calls with the nuts.;Turn: both players check. Seidel has top pair but is now drawing dead.;River: a brick. Seidel moves in and Chan insta-calls. Chan wins back to back WSOP Main Event titles.", "103");
  151.         if (!w.preferenceForKey("104"))w.setPreferenceForKey("104;Nguyen vs. McBride, 1998;Scotty Nguyen vs. Kevin McBride<br>(1998 WSOP Championship);9;Nguyen;2;4;JD9C;McBride;9;4;QH0H;8C9D9H8H8S;x;Preflop: Nguyen has the chip lead heads-up. McBride bets 50K, Nguyen calls.;Flop: Nguyen calmly check-calls 100K to trap. He's a huge favorite and he knows it.;Turn: McBride again bets 100K, drawing to one out. Nguyen flat calls with boss full house.;River: Nguyen moves in. \"You call, it'll be all over, baby.\" McBride calls and Nguyen is the 1998 WSOP champ.", "104");
  152.         if (!w.preferenceForKey("105"))w.setPreferenceForKey("105;Moneymaker vs. Farha, 2003;Chris Moneymaker vs. Sam Farha<br>(2003 WSOP Championship);9;Farha;2;4;QS9H;Moneym.;9;4;KS7H;9S2H6S8S3H;x;Preflop: Money- maker has the chip lead heads-up (4.6M to 3.8M). Moneymaker bets 100K, Farha calls.;Flop: both players check.  Farha might have been able to win the pot with a bet here.;Turn: Farha bets 300K, Moneymaker raises to 800K on a semi-bluff with straight and flush draws, Farha calls.;River: Farha checks, Moneymaker moves in. Farha asks \"You must have missed your flush, huh?\", then folds.", "105");
  153.         if (!w.preferenceForKey("106"))w.setPreferenceForKey("106;Negreanu vs. Flack, 2004;Daniel Negreanu vs. Layne Flack<br>(2004 Poker at the Plaza);1;Negreanu;2;4;KC0S;Alspach;3;1;ASJH;Smith;8;0;0H3D;Flack;9;4;8C5C;Forrest;0;2;AD4D;Deeb;1;1;8SJD;6CAC9CKS0C;x;Preflop: 5-way action with 6 players left. The slow blind structure encourages limping.;Flop: Flack opens for 9K with his flush, Forrest and Negreanu call.;Turn: Negreanu bets 24K, Flack insta-calls, Forrest folds.;River: Negreanu makes his ace-high flush, value bets 14K, and Flack pays him off.", "106");
  154.         if (!w.preferenceForKey("107"))w.setPreferenceForKey("107;Negreanu vs. Deeb, 2004;Daniel Negreanu vs. Freddy Deeb<br>(2004 Poker at the Plaza);1;Negreanu;2;4;KS9H;Alspach;3;1;7C7H;Smith;8;0;4D4H;Forrest;0;1;8CJC;Deeb;1;1;KD5C;KH8D3H????;16KC0;Preflop: The king of clubs is exposed. It would have given Deeb pocket kings. Negreanu opens for 7600 anyway.;Flop: Negreanu hits his king, announces \"Freddy! Your king hit!\", and quietly bets 12K. Nobody calls.;Turn: no post-flop action. Deeb would have flopped top set if his king hadn't been exposed.;River: no post-flop action. Deeb would have flopped top set if his king hadn't been exposed.", "107");
  155.         if (!w.preferenceForKey("108"))w.setPreferenceForKey("108;Aglialoro vs. Cassidy, 2004;John Aglialoro vs. Joe Cassidy<br>(2004 U.S. Poker Championship);2;Cassidy;2;4;KS9H;Aglialoro;9;4;7C6D;2H7D6HKD4H;x;Preflop: Cassidy limps, Aglialoro checks.  Aglialoro has 2.7 mil vs. 1.1 mil for Cassidy.;Flop: Aglialoro checks top two pair to trap but Cassidy checks behind.;Turn: bad card for Cassidy.  Aglialoro opens for 80K, Cassidy raises to 280K, Aglialoro calls.;River: Aglialoro checks, Cassidy bets 500K, Aglia- loro pushes.  Cas- sidy makes a great read and folds.", "108");
  156.         if (!w.preferenceForKey("109"))w.setPreferenceForKey("109;Ferguson vs. Hellmuth, 2005;Chris Ferguson vs. Phil Hellmuth<br>(2005 NBC National Heads-Up);9;Ferguson;2;4;9H2C;Hellmuth;9;4;AH3S;2H5H9C4H9D;x;Preflop: 3rd hand of 2nd match, Phil is up 1 to 0 in best of 3.  Phil completes to 4K, Jesus raises to 28K, Phil calls.;Flop: Jesus leads 40K with two pair, Phil calls with a gutshot.;Turn: Phil makes his straight.  Jesus check-raises, Phil moves in covering, Jesus makes a crying call.;River: Jesus fills up, Phil hits the deck, busts on the next hand.  (Phil recovers, wins the 3rd match and the title.)", "109");
  157.         if (!w.preferenceForKey("110"))w.setPreferenceForKey("110;Harman vs. Zeidman, 2005;Jennifer Harman vs. Corey Zeidman<br>(2005 WSOP Championship);9;Davis;1;1;AS6D;Harman;2;4;QDQC;Zeidman;9;4;9D8D;0SJDQH0D7D;x;Preflop: 10-handed, Harman opens for 200, Zeidman calls in LP, Brady Davis calls in the BB.;Flop: Harman bets 500 with top set, Zeidman raises to 2K with his flopped straight, Harman calls.;Turn: Harman makes boss full house and check-raises Zeidman to 3K. He thinks and calls with one out.;RIver: and there it is. Zeidman check-calls all-in and slow-rolls the stone nuts: the straight flush.", "110");
  158.         if (!w.preferenceForKey("111"))w.setPreferenceForKey("111;Matusow vs. Sheikhan, 2005;\"Mouth\" Matusow vs. \"Sheiky\" Sheikhan<br>(2005 WSOP Championship);9;Mouth;1;4;KSQH;Alsancak;2;0;????;Dannenman;3;0;????;Sheiky;8;4;ADJS;Lazar;9;0;????;Bergsdorf;0;0;????;4D0SACQSKH;x;Preflop: Sheiky moves in for about 500K, and says \"Come see daddy, MIkey.\" Mouth calls.;Flop: Mouth taunts Sheiky with \"Don't make two pair. That would suck.\";Turn: Mouth picks up some outs and says \"Now I don't wanna make two pair.\";River: Sheiky rivers the nuts and glee- fully rubs it in with \"You got what'cha deserved, sucker!\"", "111");
  159.         if (!w.preferenceForKey("112"))w.setPreferenceForKey("112;Ivey vs. Jackson, 2005;Phil Ivey vs. Paul Jackson<br>(2005 Monte Carlo Millions);8;Jackson;2;4;5S4D;Sonnert;3;3;JS9D;Ivey;8;4;KHQH;Goodwin;9;0;????;AH4H3D0D3H;x;Preflop: 10K/20K blinds, 3K ante. Sonnert opens for 50K, Ivey and Jackson call.;Flop: Sonnert opens for 105K with air, Ivey and Jackson call. Jackson's mistake #1 is not raising.;Turn: checked around. Everyone gets to see a free river card. Jackson should have bet. Mistake #2.;River: Ivey hits the ace-high flush, but the board is paired. Jackson leads 150K, Ivey thinks and makes a great call.", "112");
  160.         if (!w.preferenceForKey("113"))w.setPreferenceForKey("113;Hachem vs. Redlin, 2006;Joe Hachem vs. David Redlin<br>(2006 WPT Bellagio Five Diamond);8;Hachem;0;4;QCQH;Redlin;2;4;AHQS;Andersen;3;0;KSJH;Negreanu;8;0;8H6C;Hanna;9;0;KD7C;4D7H4HACQD;x;Preflop: Redlin opens for 180k, Hachem pops it to 500k. Redlin moves in for 725k more, Hachem calls.;Flop: rags. Hachem is a big favorite, Redlin needs an ace or running hearts.;Turn: Redlin spikes an ace. Hachem has only one out and starts cutting out chips for Redlin.;River: BOOM! The case queen knocks out Redlin in 5th. 3 hours later Hachem is passed all the sugar.", "113");
  161.         if (!w.preferenceForKey("114"))w.setPreferenceForKey("114;Negreanu vs. Hansen, 2006;Daniel Negreanu vs. Gus Hansen<br>(High Stakes Poker Season 2);1;Brunson;1;0;????;Esfandiari;2;0;ADQC;Hansen;3;4;5D5C;Negreanu;8;4;6S6H;Zeidman;9;0;????;Greenstein;0;0;????;9C6D5H5S8S;x;Preflop: Gus leads $2100, Daniel raises to $5K, Gus calls. (Amnon Filippi and Eli Elezra fold too.);Flop: Nightmare set-over-set flop for Gus. He check-raises Daniel, who calls the $26K.;Turn: Disaster for Daniel. Gus has hit his 1-outer for quads. Gus makes a weak $24K lead, Daniel thinks, calls.;River: Gus check-raises all-in for $167K, Daniel makes a crying call and loses the $575,700 pot. Ouch.", "114");
  162.         if (!w.preferenceForKey("115"))w.setPreferenceForKey("115;Furst vs. Hua, 2006;Rafe Furst vs. Can Kim Hua<br>(2006 WSOP $1500 PLH Event);0;Hua;2;4;7D2S;Furst;0;4;ASAH;Bronstein;1;0;KD0H;Enciso;8;0;????;Lynch;9;0;????;Boutin;3;0;????;7S7HQD3CAD;x;Preflop: Furst limps in with aces, Bronstein limps, Hua raises to 60K on a steal. Furst flat calls.;Flop: dream flop for Hua. He bets 55K, Furst flat calls again. Furst needs an ace or running queens.;Turn: Hua checks, Furst bets 53K thinking it is a value bet. Hua puts Furst all-in, Furst calls.;River: Furst hits his 2-outer to double up. He goes on to win his first WSOP bracelet.", "115");
  163.         if (!w.preferenceForKey("116"))w.setPreferenceForKey("116;Sagle vs. Turkewitsch, 2007;Jason Sagle vs. Soren Turkewitsch<br>(2007 WPT at Fallsview);9;Sagle;2;4;AC9D;Turkewit.;9;4;AD3C;5S9H2S4D8S;x;Preflop: Turke- witsch moves in for 4.6 million, Sagle calls covering after thinking for 1 minute.;Flop: Sagle flops his kicker but Turke- witsch now has an inside straight draw.;Turn: miracle four gives Turkewitsch his straight. Sagle can only chop with a 3 on the river.; River: Turkewitsch doubles to over 9 million, Sagle has less than 1 million. Turkewitsch goes on to win.", "116");
  164.         if (!w.preferenceForKey("117"))w.setPreferenceForKey("117;Juanda vs. Mizrachi, 2007;John Juanda vs. Michael Mizrachi<br>(2007 NBC National Heads-Up);2;Juanda;2;4;JH6H;Mizrachi;9;4;KH8C;KS3S7D6C6S;x;Preflop: Juanda moves in for 2900, Mizrachi calls covering.;Flop: Mizrachi flops top pair, Juanda needs runners.;Turn: Juanda gets one runner and now needs a jack or another six.;River: Juanda gets his second runner for trip sixes and doubles up.", "117");
  165.         if (!w.preferenceForKey("hand update id"))w.setPreferenceForKey("117", "hand update id");
  166.         buildPlayMenu();
  167.     }
  168. }
  169.  
  170. function getHandsUpdate()
  171. {
  172.     request=new XMLHttpRequest();
  173.     request.onreadystatechange=handleHttpHandsReq;
  174.     request.open("GET","http://www.floptech.com/hands/hands1.3.txt",false);
  175.     request.send(null);
  176. }
  177.  
  178. function handleHttpHandsReq()
  179. {
  180.     if (request.readyState == 4 && request.status == 200)
  181.     {
  182.         var result=request.responseText;
  183.         if (window.widget)
  184.         {
  185.             ftHid=result.substring(0,3);
  186.             var curid=widget.preferenceForKey("hand update id");
  187.             if (!curid || curid.length==0) curid="0";
  188.             if (curid!=ftHid) storeHands(result);
  189.         }
  190.     }
  191. }
  192.  
  193. function storeHands(result)
  194. {
  195.     var h,k,hs=result.split('|'),n=hs.length-1;
  196.     do{    h=hs[n]; k=h.substring(0,3);
  197.         if (k&&k.length==3) {if (!widget.preferenceForKey(k)) widget.setPreferenceForKey(h,k);}
  198.     }while(n--);
  199.     widget.setPreferenceForKey(ftHid, "hand update id");
  200. }
  201.  
  202. function buildPlayMenu()
  203. {
  204.     var w=widget, p,s, curid=handId, m=document.getElementById("popupPlayMenu"), siteid=parseInt(w.preferenceForKey("hand update id"));
  205.     while(++curid <= siteid)
  206.     {    p=w.preferenceForKey(""+curid);
  207.         if (p && p.length!=0) {s=p.split(";",2); m.options[m.options.length]=new Option(s[1],""+curid,false,false); handId=curid; }
  208.     }
  209. }
  210.  
  211. // we need to write to the .left property otherwise it can't be accessed later. go figure.
  212. function enableMoveTen() {var r, d=document, n=cardcount-1; do{r=RMT[n];r.style.left=r.offsetLeft;}while(n--);}
  213. function moveTen(n, o) {var r=RMT[n]; r.style.left=(parseInt(r.style.left)+o)+"px";}
  214. function shad() {var n=holecount-1; do {CB[n].src=tcs;}while(n--);}
  215. function unshad() {var n=holecount-1; do {if (RMT[n].innerText=='X') CB[n].src=tcb;}while(n--);}
  216. function setResultOpacity(o) {var n=playercount-1; do{RT[n].style.opacity=o;}while(n--);}
  217.  
  218. function wild(n)
  219. {
  220.     if (HC[n][rank]=='T')moveTen(n,5);
  221.     CB[n].src='images/front/cardwhite.png'; SI[n].src='images/front/wild.png';
  222.     var r=RMT[n]; r.innerText='?'; r.style.color='black'; r.style.opacity=1.0;
  223.     RM[n].selectedIndex=SM[n].selectedIndex=0; SMT[n].innerText='?'; HC[n][rank]=HC[n][suit]='?';
  224. }
  225.  
  226. function suited(n,v)
  227. {
  228.     if (HC[n][rank]=='X'){HC[n][rank]=='?';RMT[(n&01)?n-1:n+1].innerText='?';}
  229.     CB[n].src='images/front/cardwhite.png'; SI[n].src='images/front/suited.png';
  230.     var r=RMT[n]; r.style.color='black'; r.style.opacity=1.0;
  231.     SMT[n].innerText=v; SM[n].selectedIndex=0; HC[n][suit]=v;
  232. }
  233.  
  234. function paired(n,v)
  235. {
  236.     if (HC[n][rank]=='T')moveTen(n,5);
  237.     CB[n].src='images/front/cardwhite.png';
  238.     var r=RMT[n]; r.innerText=v; r.style.opacity=1.0;
  239.     RM[n].selectedIndex=0; HC[n][rank]=v;
  240.     switch (HC[n][suit])
  241.     {
  242.         case 'H':    r.style.color='darkred'; break;
  243.         case 'D':    r.style.color=diaCol; break;
  244.         case 'C':    r.style.color=clbCol; break;
  245.         case 'S':
  246.         default:    r.style.color='black'; break;
  247.     }
  248. }
  249.  
  250. function blank(n)
  251. {
  252.     if (HC[n][rank]=='T') moveTen(n,5);
  253.     CB[n].src=tcb; SI[n].src='images/front/transparent.png';
  254.     var r=RMT[n]; r.innerText='X'; r.style.color='black'; r.style.opacity=0.0;
  255.     RM[n].selectedIndex=SM[n].selectedIndex=0; SMT[n].innerText='X'; HC[n][rank]=HC[n][suit]='X';
  256. }
  257.  
  258. function resetResults()
  259. {
  260.     var cl, cr, str="--%<br>--%", n=playercount-1, nv=never, r=rank;
  261.     do{    cl=n+n; cr=cl+1;
  262.         if (HC[cl][r]!='X'&&(FS[n]>street||FS[n]==nv)&&BS[cl]==nv&&BS[cr]==nv) RT[n].innerHTML=str;
  263.     }while(n--);
  264. }
  265.  
  266. function burnFoldLabels(op)
  267. {
  268.     var cl, cr, t, st=street, bs="burn", fs="fold", pi=playercount-1, nv=never, bsl, bsr;
  269.     do{    cl=pi+pi; cr=cl+1; t=RT[pi]; t.style.opacity=op; bsl=BS[cl]; bsr=BS[cr];
  270.         if (st!=nv && st>=FS[pi]) {t.innerHTML=fs; t.style.opacity=0.5; t.style.fontSize="10px";}
  271.         else if (bsl!=nv||bsr!=nv) { t.style.fontSize="10px"; t.innerHTML=bs; if (st>=bsl||st>=bsr) t.style.opacity=op; else t.style.opacity=0.5;}
  272.         else t.style.fontSize="12px";
  273.     }while(pi--);
  274. }
  275.  
  276. function popupRankMenuChanged(elem, ind)
  277. {
  278.     if (pMode){kFoc(true); return;}
  279.     var mtx=RMT[ind], opt=elem.options[elem.selectedIndex].value;
  280.     var oin=ind&01?ind-1:ind+1, pi=ind&01?(ind-1)/2:ind/2, nv=never, r=rank, s=suit;
  281.     fInd=ind;
  282.     if (mtx.innerHTML==opt) {if (opt=='X'||opt=='=') RM[ind].selectedIndex=0; return;}
  283.     if (mtx.innerHTML=='X' && opt!='X' && opt!='x' && opt!='b' && opt !='=')
  284.     {
  285.         wild(ind);
  286.         if (RMT[oin].innerHTML=='X')wild(oin);
  287.         else if (BS[oin]!=nv)BS[ind]=street;
  288.         HC[ind][r]=opt; mtx.innerText=opt;
  289.     }
  290.     if (opt!="10" && opt!='X' && opt!='x' && opt!='b' && opt!='=')
  291.     {
  292.         if (HC[ind][r]=='T') moveTen(ind,5);
  293.         HC[ind][r]=mtx.innerText=opt;
  294.         if (ind<holecount)
  295.         {
  296.             if (BS[oin]!=nv)BS[ind]=street;
  297.             if (opt=='?' && BS[ind]!=nv && HC[ind][s]=='?')
  298.             {
  299.                 blank(ind); BS[ind]=nv;
  300.                 if (BS[oin]==nv){RT[pi].style.fontSize="12px"; RT[pi].innerHTML=" ";}
  301.             }
  302.             else if (HC[ind][s]=='='&&opt!='?'&&HC[ind][r]==HC[oin][r])
  303.             {
  304.                 HC[ind][s]=HC[oin][s]='?'; SMT[ind].innerText=SMT[oin].innerText='?'; SM[ind].selectedIndex=SM[oin].selectedIndex=0; SI[ind].src=SI[oin].src='images/front/wild.png';
  305.             }
  306.             else if (HC[oin][r]=='=')
  307.             {
  308.                 HC[oin][r]='?'; RM[oin].selectedIndex=0; RMT[oin].innerText='?';
  309.             }
  310.         }
  311.     }
  312.     else if (opt=="10")
  313.     {
  314.         if (HC[ind][r]!='T' && HC[ind][r]!='X') moveTen(ind,-5);
  315.         HC[ind][r]='T'; mtx.innerText=opt;
  316.     }
  317.     else if (opt=='b')
  318.     {
  319.         if ((HC[ind][r]=='?' && HC[ind][s]=='?') || HC[ind][r]=='X' || HC[ind][r]=='=' || HC[ind][s]=='=' || FS[pi]!=nv || ind>holecount) {RM[ind].selectedIndex=0; return;}
  320.         CB[ind].src="Images/front/cardwhite.png"; BS[ind]=street==nv?preflop:street;        
  321.         RT[pi].style.fontSize="10px"; RT[pi].innerHTML="burn";
  322.         if (HC[oin][r]=='?' && HC[oin][s]=='?') blank(oin);
  323.         else if (HC[oin][r]!='X' && BS[oin]==nv) BS[oin]=street;
  324.     }
  325.     else if (opt=='x')
  326.     {
  327.         RM[ind].selectedIndex=0;
  328.         if (HC[ind][r]=='X') {return;}
  329.         if (BS[ind]!=nv)
  330.         {
  331.             blank(ind); BS[ind]=nv;
  332.             if (BS[oin]==nv) {RT[pi].style.fontSize="12px";RT[pi].innerHTML=" ";}            
  333.         }
  334.         else if (FS[pi]==nv || FS[pi] > street)
  335.         {
  336.             FS[pi]=street==nv?preflop:street; mtx.innerText=HC[ind][r]; RT[pi].style.fontSize="10px"; RT[pi].innerHTML="fold";
  337.             if (mtx.innerText=='T') mtx.innerText="10";
  338.             handColor(ind,"gray");
  339.         }
  340.         else
  341.         {
  342.             FS[pi]=nv; RT[pi].style.fontSize="12px"; RT[pi].innerHTML="--%<br>--%";
  343.             handColor(ind,"white");
  344.         }
  345.     }    
  346.     else if (opt=='X')
  347.     {
  348.         blank(ind); blank(oin); BS[ind]=BS[oin]=FS[pi]=nv; RT[pi].innerHTML=" "; RT[pi].style.fontSize="12px";
  349.     }
  350.     else if (opt=='=')
  351.     {
  352.         if (HC[ind][s]==HC[oin][s]) {HC[oin][s]='?'; SMT[oin].innerText='?'; SM[oin].selectedIndex=0; SI[oin].src='images/front/wild.png';}
  353.         if (HC[ind][s]=='X'||HC[ind][s]=='=') {HC[ind][s]='?'; SMT[ind].innerText='?'; SM[ind].selectedIndex=0; SI[ind].src='images/front/wild.png';}
  354.         FS[pi]=BS[ind]=nv; paired(ind,'=');paired(oin,'=');
  355.     }
  356.     oi.src=oip; boardColor("white"); setResultOpacity(0.5); resetResults(); kFoc(true); fPrv=fInd; dealButtonUp(street); street=prevStr=nv;
  357.     if (sMode && fadeStats) {fadeMessage(sMsg); fadeStats=false;}
  358. }
  359.  
  360. function popupSuitMenuChanged(elem, ind)
  361. {
  362.     if (pMode){kFoc(true); return;}
  363.     var mtx=SMT[ind], opt=elem.options[elem.selectedIndex].value;
  364.     var oin=ind&01?ind-1:ind+1, pi=ind&01?(ind-1)/2:ind/2, nv=never, r=rank, s=suit;
  365.     fInd=ind;
  366.     if (mtx.innerHTML==opt) {if (opt=='X'||opt=='=') RM[ind].selectedIndex=0; return;}
  367.     if (mtx.innerHTML=='X' && opt!='X' && opt!='x' && opt!='b') {wild(ind); if (RMT[oin].innerHTML=='X') wild(oin);}
  368.     if (opt == '?')
  369.     {
  370.         SI[ind].src='images/front/wild.png'; RMT[ind].style.color='black'; mtx.innerText=HC[ind][s]=opt;
  371.         if (BS[ind]!=nv && HC[ind][r]=='?' && ind<holecount)
  372.         {
  373.             blank(ind);    BS[ind]=nv;
  374.             if (BS[oin]==nv) {RT[pi].style.fontSize="12px"; RT[pi].innerHTML=" ";}            
  375.         }
  376.         else if (HC[oin][s]=='=')
  377.         {
  378.             SMT[oin]=HC[oin][s]='?'; SM[oin].selectedIndex=0; SI[oin].src='images/front/wild.png'; RMT[oin].style.color='black';
  379.         }
  380.     }
  381.     else if (opt=='b')
  382.     {
  383.         if ((HC[ind][r]=='?' && HC[ind][s]=='?') || HC[ind][r]=='X' || HC[ind][r]=='=' || HC[ind][s]=='=' || FS[pi]!=nv || ind>holecount) {SM[ind].selectedIndex=0; return;}
  384.         CB[ind].src="Images/front/cardwhite.png"; BS[ind]=street==nv?preflop:street;
  385.         RT[pi].style.fontSize="10px"; RT[pi].innerHTML="burn"; mtx.innerText=HC[ind][s];
  386.         if (HC[oin][r]=='?' && HC[oin][s]=='?') blank(oin);
  387.         else if (HC[oin][r]!='X' && BS[oin]==nv) BS[oin]==street==nv?preflop:street;
  388.     }
  389.     else if (opt=='x')
  390.     {
  391.         SM[ind].selectedIndex=0;
  392.         if (HC[ind][s]=='X') {return;}
  393.         if (BS[ind]!=nv)
  394.         {
  395.             blank(ind); BS[ind]=nv;
  396.             if (BS[oin]==nv) {RT[pi].style.fontSize="12px"; RT[pi].innerHTML=" ";}            
  397.         }
  398.         else if (FS[pi]==nv || FS[pi] > street)
  399.         {
  400.             FS[pi]=street==nv?preflop:street; RT[pi].style.fontSize="10px"; RT[pi].innerHTML="fold"; mtx.innerText=HC[ind][s]; handColor(ind,"gray");
  401.         }
  402.         else
  403.         {
  404.             FS[pi]=nv; RT[pi].style.fontSize="12px"; RT[pi].innerHTML="--%<br>--%"; handColor(ind,"white");
  405.         }
  406.     }
  407.     else if (opt=='X')
  408.     {
  409.         blank(ind); blank(oin); BS[ind]=BS[oin]=FS[pi]=nv;
  410.         RMT[ind].style.color='black'; SI[ind].src='images/front/transparent.png'; 
  411.         RT[pi].innerHTML=" "; RT[pi].style.fontSize="12px";
  412.     }
  413.     else if (opt=='=')
  414.     {
  415.         if (HC[ind][r]==HC[oin][r]) wild(oin);
  416.         if (HC[ind][r]=='=') {wild(ind);}
  417.         FS[pi]=BS[ind]=nv;RMT[ind].style.color='black'; RT[pi].innerHTML="--%<br>--%";
  418.         suited(ind,'=');suited(oin,'=');
  419.     }
  420.     else
  421.     {
  422.         if (opt=='S') {SI[ind].src='Images/front/spade.png'; RMT[ind].style.color='black';}
  423.         else if (opt=='H') {SI[ind].src='Images/front/heart.png'; RMT[ind].style.color='darkred';}
  424.         else if (opt=='D') {SI[ind].src=diaImg; RMT[ind].style.color=diaCol;}
  425.         else if (opt=='C') {SI[ind].src=clbImg; RMT[ind].style.color=clbCol;}
  426.         mtx.innerText=HC[ind][s]=opt;
  427.         if (ind < holecount)
  428.         {
  429.             if (HC[ind][r]=='='&&HC[ind][s]==HC[oin][s])
  430.             {
  431.                 HC[ind][r]=HC[oin][r]='?'; RMT[ind].innerText=RMT[oin].innerText='?'; RM[ind].selectedIndex=RM[oin].selectedIndex=0;
  432.             }
  433.             else if (HC[oin][s]=='=')
  434.             {
  435.                 HC[oin][s]='?'; SM[oin].selectedIndex=0; SI[oin].src='images/front/wild.png'; RMT[oin].style.color='black';
  436.             }
  437.         }
  438.     }
  439.     setResultOpacity(0.5); resetResults(); boardColor("white");
  440.     oi.src=oip; kFoc(true); fPrv=fInd; dealButtonUp(street); street=prevStr=nv;
  441.     if (sMode&&fadeStats) {fadeMessage(sMsg); fadeStats=false;}
  442. }
  443.  
  444. function messageModeChanged(elem)
  445. {
  446.     if (elem.selectedIndex==0)
  447.     {
  448.         mt.innerHTML=PokerPlugin.getResult('q'); sMode=false; times=0;
  449.         if (pMode) mt.innerHTML=HT[street];
  450.     }
  451.     else
  452.     {
  453.         seat=elem.options[elem.selectedIndex].value;
  454.         setStatMsg(seat); fadeMessage(sMsg); sMode=true;
  455.     }
  456. }
  457.  
  458. function dealCountChanged(elem) {deals=elem.options[elem.selectedIndex].value;}
  459. function errStatMsg() {sMsg="<br>Please choose an un-folded hand for statistics";}
  460. function setStatMsg(s)
  461. {
  462.     if (s!='1'&&s!='2'&&s!='3'&&s!='8'&&s!='9'&&s!='a') {errStatMsg(); return;}
  463.     var u=(s=='a'?"10":s);
  464.     sMsg="<br>Statistics mode:<br>seat "+u;
  465.     if (pMode)
  466.     {
  467.         var t=document.getElementById("seatTitle"+u); sName=t.innerHTML;
  468.         if (sName==" " || sName=="") {errStatMsg(); return;}
  469.         sMsg +=": "+sName; sName +=": ";
  470.     }
  471.     else
  472.     {
  473.         sName="seat "+u+": ";
  474.     }
  475. }
  476.  
  477. function dealPreflopButtonOver(){DB[0].src=street==preflop?dpbdo:dpbo}
  478. function dealFlopButtonOver()    {DB[1].src=street==flop?dfbdo:dfbo}
  479. function dealTurnButtonOver()    {DB[2].src=street==turn?dtbdo:dtbo}
  480. function dealRiverButtonOver()    {DB[3].src=street==river?drbdo:drbo}
  481. function dealPreFlopButtonDown(){if (prevStr!=preflop)    dealButtonUp(prevStr);    prevStr=street;street=preflop; DB[0].src=dpbdo;    setTimeout("dealpreflop();",0);}
  482. function dealFlopButtonDown()    {if (prevStr!=flop)        dealButtonUp(prevStr);    prevStr=street;street=flop; DB[1].src=dfbdo;    setTimeout("dealflop();",0);}
  483. function dealTurnButtonDown()    {if (prevStr!=turn)        dealButtonUp(prevStr);    prevStr=street;street=turn; DB[2].src=dtbdo;    setTimeout("dealturn();",0);}
  484. function dealRiverButtonDown()    {if (prevStr!=river)    dealButtonUp(prevStr);    prevStr=street;street=river; DB[3].src=drbdo;    setTimeout("dealriver();",0);}
  485. function dealPreFlopButtonOut()    {DB[0].src=street==preflop?dpbd:dpb}
  486. function dealFlopButtonOut()    {DB[1].src=street==flop?dfbd:dfb}
  487. function dealTurnButtonOut()    {DB[2].src=street==turn?dtbd:dtb}
  488. function dealRiverButtonOut()    {DB[3].src=street==river?drbd:drb}
  489. function dealButtonUp(s) {if (s!=never)DB[s].src="Images/themes/"+theme+"/deal"+SS[s]+".png";}
  490. function rbButtonOver() {resetBoardButton.src='Images/themes/'+theme+'/resetboardover.png'; shadowFlopImage.src='Images/themes/'+theme+'/flopglow.png'; shadowTurnImage.src=shadowRiverImage.src='Images/themes/'+theme+'/boardglow.png';}
  491. function rhButtonOver() {resetHandsButton.src='Images/themes/'+theme+'/resethandsover.png'; SH[0].src=SH[1].src=SH[2].src=SH[3].src=SH[4].src=SH[5].src=SH[6].src=SH[7].src=SH[8].src=SH[9].src=hsg;}
  492. function rbButtonOut() {resetBoardButton.src='Images/themes/'+theme+'/resetboard.png'; shadowFlopImage.src='Images/front/flopshadow.png'; shadowTurnImage.src=shadowRiverImage.src='Images/front/boardshadow.png'; kFoc(false);}
  493. function rhButtonOut() {resetHandsButton.src='Images/themes/'+theme+'/resethands.png'; SH[0].src=SH[1].src=SH[2].src=SH[3].src=SH[4].src=SH[5].src=SH[6].src=SH[7].src=SH[8].src=SH[9].src=hsh; kFoc(false);}
  494. function rbButtonDown() {resetBoardButton.src='Images/themes/'+theme+'/resetboarddownover.png'; dealButtonUp(street); setTimeout("reset(0); kFoc(false);",0);}
  495. function rhButtonDown() {resetHandsButton.src='Images/themes/'+theme+'/resethandsdownover.png'; dealButtonUp(street); setTimeout("reset(1); kFoc(false);",0);}
  496.  
  497. function reset(what)
  498. {
  499.     var n, p=pMode; pMode=false; hPrev=0; oi.src=oip;
  500.     boardColor("white"); setResultOpacity(0.5); resetResults();
  501.     if (what==0 || what==2)    {var c=holecount; n=4; do{wild(c++);}while(n--);}
  502.     if (what==1 || what==2)
  503.     {
  504.         var nv=never; n=holecount-1;
  505.         do{blank(n);BS[n]=nv;}while(n--);
  506.         n=playercount-1;
  507.         do{RT[n].innerHTML=" ";FS[n]=nv;}while(n--);
  508.     }
  509.  
  510.     if (sMode && !error)
  511.     {
  512.         if (what==1 || what==2) {setStat(0); fadeMessage(PokerPlugin.getResult('q'));}
  513.         else {setStatMsg(seat); fadeMessage(sMsg);}
  514.     }
  515.     else if (p && !error)
  516.         fadeMessage(PokerPlugin.getResult('q'));
  517.  
  518.     fInd=0;fItm=rank;unshad();street=prevStr=never;
  519.     if (!p) return;
  520.     count=0; document.getElementById('handTitle').innerHTML=" ";
  521.     var t=document.getElementById("popupPlayMenu");
  522.     t.selectedIndex=0; t.value=t.options[0].value; eraseSeatTitles();
  523.     document.getElementById(btnImg).src='Images/front/nobutton.png';
  524. }
  525.  
  526. function changeCardColors()
  527. {
  528.     var n=cardcount-1;
  529.     do{    if (HC[n][suit]=='C') {RMT[n].style.color=clbCol; SI[n].src=clbImg;}
  530.         else if (HC[n][suit]=='D') {RMT[n].style.color=diaCol; SI[n].src=diaImg;}
  531.     }while(n--);
  532. }
  533.  
  534. function fourColorClicked()
  535. {
  536.     fourColor=fourColor?false:true;
  537.     if (fourColor) { clbCol='darkgreen'; diaCol='darkblue'; clbImg='images/front/clubgreen.png'; diaImg='images/front/diamondblue.png'; }
  538.     else {clbCol='black'; diaCol='darkred'; clbImg='images/front/clubblack.png'; diaImg='images/front/diamondred.png';}
  539.     changeCardColors();
  540. }
  541.  
  542. function newsAlertClicked()
  543. {
  544.     newsAlert=newsAlert?false:true;
  545.     if (newsAlert) {checkForNewsUpdate();}
  546.     else {newsStat="normal"; newsDate="0";}
  547. }
  548.  
  549. function themeChanged(elem)
  550. {
  551.     thInd=elem.selectedIndex; theme=elem.options[thInd].value;
  552.     var t='Images/themes/'+theme+'/';
  553.     fi.src=t+'front.png'; tcb=t+'cardback.png'; tcs=t+'cardbackshad.png';
  554.     var r=rank, n=holecount-1;
  555.     do {if (HC[n][r]=='X') CB[n].src=(pMode?tcs:tcb);}while(n--);
  556.     resetHandsButton.src=t+'resetHands.png';resetBoardButton.src=t+'resetboard.png';dealPreFlopButton.src=t+'dealpreflop.png';dealFlopButton.src=t+'dealflop.png';dealTurnButton.src=t+'dealturn.png';dealRiverButton.src=t+'dealriver.png';
  557.     if (street!=never && street!=preflop) oi.src=t+'outline'+SS[street]+'.png';
  558.     oif=t+'outlineflop.png';oit=t+'outlineturn.png';oir=t+'outlineriver.png';hsg=t+'holeglow.png';
  559.     dpb=t+'dealpreflop.png';dfb=t+'dealflop.png';dtb=t+'dealturn.png';drb=t+'dealriver.png';dpbd=t+'dealpreflopdown.png';dfbd=t+'dealflopdown.png';dtbd=t+'dealturndown.png';drbd=t+'dealriverdown.png';
  560.     dpbo=t+'dealpreflopover.png';dfbo=t+'dealflopover.png';dtbo=t+'dealturnover.png';drbo=t+'dealriverover.png';dpbdo=t+'dealpreflopdownover.png';dfbdo=t+'dealflopdownover.png';dtbdo=t+'dealturndownover.png';drbdo=t+'dealriverdownover.png';
  561.     if (street!=never) DB[street].src="Images/themes/"+theme+"/deal"+SS[street]+"down.png";
  562. }
  563.  
  564. function playChanged(elem)
  565. {
  566.     var h=elem.selectedIndex;
  567.     curShad();
  568.     if (h==hPrev) return;
  569.     dealButtonUp(street);
  570.     if (h==0) {setStat(0); reset(2); hPrev=0;}
  571.     else if (h==1) {getHandsUpdate(); buildPlayMenu(); elem.selectedIndex=pMode?hPrev:0; elem.value=elem.options[pMode?hPrev:0].value;}
  572.     else {setStat(0); pMode=false; reset(2); pMode=true; shad(); setUpPlayback(elem.options[elem.selectedIndex].value);hPrev=h;}
  573. }
  574.  
  575. function setUpPlayback(handId)
  576. {
  577.     var p=widget.preferenceForKey(handId);
  578.     if (!p || p.length==0)return;
  579.     eraseSeatTitles(); document.getElementById(btnImg).src='Images/front/nobutton.png';
  580.     var a=p.split(";");
  581.     document.getElementById('handTitle').innerHTML=a[2];
  582.     var b=a[3];
  583.     if (b!='x') { btnImg="button"+b; document.getElementById(btnImg).src='Images/front/button.png';}
  584.     pMode=false;
  585.     var i=4, l=a.length;
  586.     while (l>(i+6)) {setHand(a[i],a[i+1],a[i+2],a[i+3]); i+=4;}
  587.     setBoard(a[i++]); setBurnCards(a[i++]);
  588.     pMode=true;
  589.     HT[preflop]=a[i++]; HT[flop]=a[i++]; HT[turn]=a[i++]; HT[river]=a[i]; mt.innerHTML=HT[preflop];
  590.     street=preflop;prevStr=preflop; DB[street].src="Images/themes/"+theme+"/dealpreflopdown.png";
  591. }
  592.  
  593. function setHand(n, s, f, h)
  594. {
  595.     var sn=parseInt(s);
  596.     if (sn==0) sn=10;
  597.     document.getElementById('seatTitle'+sn).innerHTML=n;
  598.     var si=sn-1; RT[si].style.opacity=0.5; FS[si]=parseInt(f);
  599.     if (FS[si]==preflop) { RT[si].innerHTML="fold"; RT[si].style.fontSize="10px";}
  600.     else { RT[si].innerHTML="--%<br>--%"; RT[si].style.fontSize="12px";}
  601.     var ci=si+si, ra=rank, su=suit;
  602.     mouseFocus(ci,ra); kbdRank(h[ra]); mouseFocus(ci,su); kbdSuit(h[su]);
  603.     ci++; mouseFocus(ci,ra); kbdRank(h[ra+2]); mouseFocus(ci,su); kbdSuit(h[su+2]); mouseBlur();
  604. }
  605.  
  606. function setBoard(s)
  607. {
  608.     var i=0, c=holecount, ra=rank, su=suit, n=4;
  609.     do{mouseFocus(c,ra);kbdRank(s[i++]);mouseFocus(c++,su);kbdSuit(s[i++]);}while(n--);
  610.     mouseBlur(); boardColor("gray");
  611. }
  612.  
  613. function setBurnCards(s)
  614. {
  615.     if (s.length==1) return;
  616.     var x, n=0, c=0, ra=rank, su=suit;
  617.     while (n<s.length)
  618.     {
  619.         c=parseInt(s.charAt(n++)+s.charAt(n++)); mouseFocus(c,ra); kbdRank(s.charAt(n++));
  620.         mouseFocus(c,su); kbdSuit(s.charAt(n++));
  621.         x=street; street=parseInt(s.charAt(n++)); kbdRank('b'); street=x;
  622.     }
  623.     mouseBlur();
  624. }
  625.  
  626. function fadeMessage(m) {doFade(0,0.0); fi.src='Images/themes/'+theme+'/front.png'; mt.innerHTML=m; setTimeout("doFade(300,1.0);",0);}
  627. function doFade(d, o) {if (A.tmr!=null) {clearInterval(A.tmr); A.tmr=null;} A.dur=d; A.st=(new Date).getTime()-13; A.first=mt; A.tmr=setInterval("animate(A);",13); A.from=A.now; A.to=o; animate(A);}
  628.  
  629. function eraseSeatTitles()
  630. {
  631.     var t, n=3, d=document;
  632.     do{    t=d.getElementById("seatTitle"+n); t.innerHTML=" "; t.style.opacity=1.0;
  633.         t=d.getElementById("seatTitle"+(n+7)); t.innerHTML=" "; t.style.opacity=1.0;
  634.     }while(--n);
  635. }
  636.  
  637. function setStat(i)
  638. {
  639.     var menu=document.getElementById("popupMessageModeMenu"); menu.selectedIndex=i; menu.value=menu.options[i].value;
  640.     if (i == 0) {sMode=false; seat="X";}
  641.     else {sMode=true; seat=i==10?'a':""+i;}
  642. }
  643.  
  644. function newsButtonGlow() {newsButtonImage.src='Images/back/news'+newsStat+'glow.png';}
  645. function newsButtonDark() {newsButtonImage.src='Images/back/news.png';}
  646. function newsButtonClicked()
  647. {
  648.      if (window.widget)
  649.      {
  650.         widget.openURL(newsURL); now=new Date();
  651.         newsDate=now.getDate(); newsStat="normal"; newsURL="http://www.floptech.com/news/news.html";
  652.         widget.setPreferenceForKey(ftNid,"news update id");
  653.     }
  654. }
  655.  
  656. function boardColor(color) {CB[20].src=CB[21].src=CB[22].src=CB[23].src=CB[24].src="Images/front/card"+color+".png";}
  657.  
  658. function handColor(i, c)
  659. {
  660.     var o=(i&01)?(i-1):(i+1);
  661.     CB[i].src=CB[o].src="Images/front/card"+c+".png";
  662.     if (pMode) {var s=((i&01)?(o/2):(i/2))+1; document.getElementById("seatTitle"+s).style.opacity=(c=="gray")?0.5:1.0;}
  663. }
  664.  
  665. function focused() {foc=true; kFoc(false);}
  666. function blurred() {curShad(); foc=false;}
  667. function mouseFocus(cardind, carditem) {if (foc) {curShad(); fInd=cardind; fItm=carditem; kFoc(true);}}
  668. function mouseBlur() {curShad(); fInd=fPrv;}
  669. function kFoc(g) {document.getElementById('kbdInputArea').focus();if (!pMode && g) curGlow();}
  670.  
  671. function curGlow()
  672. {
  673.     if (fInd<holecount)    SH[(fInd&01?(fInd-1)/2:fInd/2)].src=hsg;
  674.     else if (fInd<23)    shadowFlopImage.src='Images/themes/'+theme+'/flopglow.png';
  675.     else if (fInd==23)    shadowTurnImage.src='Images/themes/'+theme+'/boardglow.png';
  676.     else shadowRiverImage.src='Images/themes/'+theme+'/boardglow.png';
  677. }
  678.  
  679. function curShad()
  680. {
  681.     if (fInd<holecount)    SH[(fInd&01?(fInd-1)/2:fInd/2)].src=hsh;
  682.     else if (fInd<23)    shadowFlopImage.src='Images/front/flopshadow.png';
  683.     else if (fInd==23)    shadowTurnImage.src='Images/front/boardshadow.png';
  684.     else shadowRiverImage.src='Images/front/boardshadow.png';
  685. }
  686.  
  687. function kbdHole(keychar)
  688. {
  689.     if (pMode) return;
  690.     var f=rank;
  691.     curShad();
  692.     switch (keychar)
  693.     {
  694.       case '!':    // <shift>1
  695.       case 'v':    // player zero
  696.         fInd=0; break;
  697.       case '@':    // <shift>2
  698.         fInd=2; break;
  699.       case '#':    // <shift>3
  700.         fInd=4; break;
  701.       case '$':    // <shift>4
  702.         fInd=6; break;
  703.       case '%':    // <shift>5
  704.         fInd=8; break;
  705.       case '^':    // <shift>6
  706.         fInd=10; break;
  707.       case '&':    // <shift>7
  708.         fInd=12; break;
  709.       case '*':    // <shift>8
  710.         fInd=14; break;
  711.       case '(':    // <shift>9
  712.         fInd=16; break;
  713.       case ')':    // <shift>0
  714.       case 'n':    // player nine
  715.         fInd=18; break;
  716.       case 'f':    // flop
  717.           fInd=20; break;
  718.       case 't':    // turn
  719.           fInd=23; break;
  720.       case 'r':    // river
  721.           fInd=24; break;
  722.       case '[':
  723.           if (fInd<20) {if (fInd & 01)fInd--;}
  724.           else if (fInd==21||fInd==22)fInd--;
  725.           f=rank;
  726.           break;
  727.       case ']':
  728.           if (fInd<20){if (!(fInd & 01))fInd++;}
  729.           else if (fInd==20 || fInd==21)fInd++;
  730.           f=rank;
  731.         break;
  732.       case '{':
  733.           if (fInd<20) {if (fInd & 01)fInd--;}
  734.           else if (fInd==21||fInd==22)fInd--;
  735.           f=suit;
  736.           break;
  737.       case '}':
  738.           if (fInd<20){if (!(fInd & 01))fInd++;}
  739.           else if (fInd==20 || fInd==21)fInd++;
  740.           f=suit;
  741.         break;
  742.       default:
  743.           return false;
  744.     };
  745.     curGlow(); fItm=f; fPrv=fInd;
  746.     return true;
  747. }
  748.  
  749. function kbdBtn(keychar)
  750. {
  751.     switch (keychar)
  752.     {
  753.       case 'P':
  754.         dealPreFlopButtonDown();dealPreFlopButtonOut();
  755.         return true;
  756.       case 'F':
  757.         dealFlopButtonDown();dealFlopButtonOut();
  758.         return true;
  759.       case 'T':
  760.         dealTurnButtonDown();dealTurnButtonOut();
  761.         return true;
  762.       case 'R':
  763.         dealRiverButtonDown();dealRiverButtonOut();
  764.         return true;
  765.       case 'B':
  766.           dealButtonUp(street); reset(0); kFoc(false);
  767.           return true;
  768.       case 'H':
  769.           dealButtonUp(street); reset(1); kFoc(false);
  770.           return true;
  771.       case 'A':
  772.           dealButtonUp(street); reset(2); kFoc(false);
  773.           return true;
  774.       default:
  775.           break;
  776.     };
  777.     return false;
  778. }
  779.  
  780. function kbdNext(keycode, keychar)
  781. {
  782.     if (pMode) return;
  783.     if (keycode==13)
  784.     {
  785.         if (fInd<18)
  786.         {
  787.             fInd=fInd&01?(fInd-1):fInd; 
  788.             SH[fInd/2].src=hsh;
  789.             fInd+=2;
  790.             SH[fInd/2].src=hsg;
  791.         }
  792.         else if (fInd<20)
  793.         {
  794.             SH[fInd/2].src=hsh;
  795.             fInd=20;
  796.             shadowFlopImage.src='Images/themes/'+theme+'/flopglow.png';
  797.         }
  798.         else if (fInd<23)
  799.         {
  800.             changeImages('shadowFlopImage','Images/front/flopshadow.png');
  801.             fInd=23;
  802.             shadowTurnImage.src='Images/themes/'+theme+'/boardglow.png';
  803.         }
  804.         else if (fInd==23)
  805.         {
  806.             changeImages('shadowTurnImage','Images/front/boardshadow.png');
  807.             fInd=24;
  808.             shadowRiverImage.src='Images/themes/'+theme+'/boardglow.png';
  809.         }
  810.         else
  811.         {
  812.             changeImages('shadowRiverImage','Images/front/boardshadow.png');
  813.             fInd=0;
  814.             SH[0].src=hsg;
  815.         }
  816.         fItm=rank; fPrv=fInd;
  817.         return true;
  818.     }
  819.     return false;
  820. }
  821.  
  822. function kbdPrev(keycode, keychar)
  823. {
  824.     if (pMode) return;
  825.     if (keychar==' ')
  826.     {
  827.         if (fInd<2)
  828.         {
  829.             SH[0].src=hsh;
  830.             fInd=24;
  831.             shadowRiverImage.src='Images/themes/'+theme+'/boardglow.png';
  832.         }
  833.         else if (fInd<20)
  834.         {
  835.             fInd=fInd&01?(fInd-1):fInd;
  836.             SH[fInd/2].src=hsh;
  837.             fInd -= 2;
  838.             SH[fInd/2].src=hsg;
  839.         }
  840.         else if (fInd<23)
  841.         {
  842.             shadowFlopImage.src='Images/front/flopshadow.png';
  843.             fInd=18;
  844.             SH[9].src=hsg;
  845.         }
  846.         else if (fInd==23)
  847.         {
  848.             shadowTurnImage.src='Images/front/boardshadow.png';
  849.             fInd=20;
  850.             shadowFlopImage.src='Images/themes/'+theme+'/flopglow.png';
  851.         }
  852.         else
  853.         {
  854.             shadowRiverImage.src='Images/front/boardshadow.png';
  855.             fInd=23;
  856.             shadowTurnImage.src='Images/themes/'+theme+'/boardglow.png';
  857.         }
  858.         fItm=rank; fPrv=fInd;
  859.         return true;
  860.     }
  861.     return false;
  862. }
  863.  
  864. function kbdRank(str)
  865. {
  866.     var ind=0, keychar=str[0];
  867.     switch (keychar)
  868.     {
  869.       case 'a':
  870.       case 'A':
  871.         ind=0; break;
  872.       case 'k':
  873.       case 'K':
  874.         ind=1; break;
  875.       case 'q':
  876.       case 'Q':
  877.         ind=2; break;
  878.       case 'j':
  879.       case 'J':
  880.         ind=3; break;
  881.       case '0':
  882.         ind=4; break;
  883.       case '9':
  884.         ind=5; break;
  885.       case '8':
  886.         ind=6; break;
  887.       case '7':
  888.         ind=7; break;
  889.       case '6':
  890.         ind=8; break;
  891.       case '5':
  892.         ind=9; break;
  893.       case '4':
  894.         ind=10; break;
  895.       case '3':
  896.         ind=11; break;
  897.       case '2':
  898.         ind=12; break;
  899.       case '?':
  900.       case 'w':
  901.         ind=13; break;
  902.       case 'x':
  903.         ind=14; break;
  904.       case 'b':
  905.         ind=15; break;
  906.       case 'X':
  907.         ind=16; break;
  908.       case '=':
  909.         ind=17; break;
  910.       default:
  911.         return false;
  912.     }
  913.     RM[fInd].selectedIndex=ind; popupRankMenuChanged(RM[fInd],fInd); fPrv=fInd;
  914.     return true;
  915. }
  916.  
  917. function kbdSuit(str)
  918. {
  919.     var ind=0, keychar=str[0];
  920.     switch (keychar)
  921.     {
  922.       case 's':
  923.       case 'S':
  924.         ind=0; break;
  925.       case 'h':
  926.       case 'H':
  927.         ind=1; break;
  928.       case 'd':
  929.       case 'D':
  930.         ind=2; break;
  931.       case 'c':
  932.       case 'C':
  933.         ind=3; break;
  934.       case '?':
  935.       case 'w':
  936.         ind=4; break;
  937.       case 'x':
  938.         ind=5; break;
  939.       case 'b':
  940.         ind=6; break;
  941.       case 'X':
  942.         ind=7; break;
  943.       case '=':
  944.         ind=8; break;
  945.       default:
  946.         return false;
  947.     }
  948.     SM[fInd].selectedIndex=ind; popupSuitMenuChanged(SM[fInd], fInd); fPrv=fInd;
  949.     return true;
  950. }
  951.  
  952. function kbdStat(k)
  953. {
  954.     var s;
  955.     switch (k)
  956.     {
  957.       case 8260: // <shift><opt>1 etc. for seat numbers
  958.           s=1; break;
  959.       case 8364:
  960.           s=2; break;
  961.       case 8249:
  962.           s=3; break;
  963.       case 8250:
  964.           s=4; break;
  965.       case 64257:
  966.           s=5; break;
  967.       case 64258:
  968.           s=6; break;
  969.       case 8225:
  970.           s=7; break;
  971.       case 176:
  972.           s=8; break;
  973.       case 183:
  974.           s=9; break;
  975.       case 8218:
  976.           s=10; break;
  977.       case 8212: // <shift><opt>- to cancel
  978.           s=11; break;
  979.       default:
  980.           return false;
  981.     };
  982.     if (s==11)
  983.     {
  984.         if (!sMode) return;
  985.         setStat(0); sMsg=pMode?HT[street]:PokerPlugin.getResult('q'); sMode=false; times=0;
  986.     }
  987.     else
  988.     {
  989.         if ((s==10 && seat=='a') || (seat==""+s)) return;
  990.         setStat(s); setStatMsg(s==10?'a':""+s); sMode=true;
  991.     }
  992.     fadeMessage(sMsg);
  993.     return true;
  994. }
  995.  
  996. function kbdTog(k)
  997. {
  998.     switch (k)
  999.     {
  1000.       case 711: // <shift><opt>t to toggle tooltips
  1001.         if (ttOn) fadeMessage("<br>Tooltips off");
  1002.         else fadeMessage("<br>Tooltips on");
  1003.         ttOn=!ttOn; tooltipsCheck.checked=ttOn; times=0;
  1004.           return true;
  1005.       default:
  1006.           return false;
  1007.     };
  1008.     return false;
  1009. }
  1010.  
  1011. function kbdEvent(k)
  1012. {
  1013.     var keycode=k.keyCode, keychar=String.fromCharCode(keycode), r=rank;
  1014.     if (kbdBtn(keychar)) return;
  1015.     if (!pMode && kbdHole(keychar)) return;
  1016.     if (kbdStat(keycode)) return;
  1017.     if (kbdTog(keycode)) return;
  1018.     if (pMode || kbdNext(keycode,keychar) || kbdPrev(keycode,keychar)) return;
  1019.     curGlow();
  1020.     if (fItm==r) {if (!kbdRank(keychar)) return;}
  1021.     else if (!kbdSuit(keychar)) return;
  1022.     if ((keychar=='x' || keychar=='X') && fInd<holecount) {fInd=fInd&01?(fInd-1):fInd; fItm=r; curGlow(); return;}
  1023.     fItm=(fItm==r?suit:r);
  1024.     if (fItm==r)
  1025.     {
  1026.         if (fInd<holecount)
  1027.             fInd=fInd&01?(fInd-1):(fInd+1);
  1028.         else if (fInd<(holecount+3))
  1029.             fInd=fInd<(holecount+2)?(fInd+1):holecount;
  1030.         fPrv=fInd;
  1031.     }
  1032. }
  1033.  
  1034. function foldAndBurn()
  1035. {
  1036.     var c, cr, st=street, nv=never, p=playercount-1, r=rank, s=suit, cbw="Images/front/cardwhite.png", cbg="Images/front/cardgray.png";
  1037.     do {c=p+p; cr=c+1;
  1038.         if (HC[c][r]=='X')    continue;
  1039.         else if (st>=FS[p])    {DC[c][r]=HC[c][r]; DC[c][s]=HC[c][s]; DC[cr][r]=HC[cr][r]; DC[cr][s]=HC[cr][s]; HC[c][r]=HC[cr][r]='X'; handColor(c,"gray");}
  1040.         else if (BS[c]==nv&&BS[cr]==nv) handColor(c,"white");
  1041.         else
  1042.         {    if (BS[c]!=nv)
  1043.             {
  1044.                 if (st>=BS[c]) {DC[c][r]=HC[c][r]; DC[c][s]=HC[c][s]; HC[c][r]='X'; CB[c].src=cbw;}
  1045.                 else {BC[c][r]=HC[c][r]; BC[c][s]=HC[c][s]; HC[c][r]='X'; CB[c].src=cbg;}
  1046.             }
  1047.             if (BS[cr]!=nv)
  1048.             {
  1049.                 if (st>=BS[cr]) {DC[cr][r]=HC[cr][r]; DC[cr][s]=HC[cr][s]; HC[cr][r]='X'; CB[cr].src=cbw;}
  1050.                 else {BC[cr][r]=HC[cr][r]; BC[cr][s]=HC[cr][s]; HC[cr][r]='X'; CB[cr].src=cbg;}
  1051.             }
  1052.         }
  1053.     }while(p--);
  1054. }
  1055.  
  1056. function unFoldAndUnBurn()
  1057. {
  1058.     var n=holecount-1, r=rank, s=suit;
  1059.     do{    if (DC[n][r]!='X') {HC[n][r]=DC[n][r]; HC[n][s]=DC[n][s]; DC[n][r]='X';}
  1060.         else if (BC[n][r]!='X') {HC[n][r]=BC[n][r]; HC[n][s]=BC[n][s]; BC[n][r]='X';}
  1061.     }while(n--);
  1062. }
  1063.  
  1064. function dealpreflop()
  1065. {
  1066.     error=false;
  1067.     deal(0); oi.src=oip;
  1068.     if (!error) boardColor("gray");
  1069.     kFoc(false);
  1070. }
  1071.  
  1072. function dealflop()
  1073. {
  1074.     error=false;
  1075.     deal(3);
  1076.     if (!error)
  1077.     {
  1078.         oi.src=oif;
  1079.         CB[20].src=CB[21].src=CB[22].src="Images/front/cardwhite.png";
  1080.         CB[23].src=CB[24].src="Images/front/cardgray.png";
  1081.     }
  1082.     else
  1083.     {
  1084.         oi.src=oip;
  1085.     }
  1086.     kFoc(false);
  1087. }
  1088.  
  1089. function dealturn()
  1090. {
  1091.     error=false;
  1092.     deal(4);
  1093.     if (!error)
  1094.     {
  1095.         oi.src=oit;
  1096.         CB[20].src=CB[21].src=CB[22].src=CB[23].src="Images/front/cardwhite.png";
  1097.         CB[24].src="Images/front/cardgray.png";
  1098.     }
  1099.     else
  1100.     {
  1101.         oi.src=oip;
  1102.     }
  1103.     kFoc(false);
  1104. }
  1105.  
  1106. function dealriver()
  1107. {
  1108.     error=false;
  1109.     deal(5);
  1110.     if (!error)
  1111.     {
  1112.         oi.src=oir;
  1113.         boardColor("white");
  1114.     }
  1115.     else
  1116.     {
  1117.         oi.src=oip;
  1118.     }
  1119.     kFoc(false);
  1120. }
  1121.  
  1122. function deal(num)
  1123. {
  1124.     if (!PokerPlugin) {mt.innerHTML="oops: plugin not loaded"; alert("PokerPlugin plugin not loaded."); return;}
  1125.     var i,n,r,s,res,arg='', ri=rank, su=suit, op=1.0;
  1126.     foldAndBurn();
  1127.     i=0; n=holecount;
  1128.     do {arg+=HC[i][ri]+HC[i++][su];}while(--n);
  1129.     i=-1; n=5;
  1130.     do {if (++i<num) arg+=HC[20+i][ri]+HC[20+i][su]; else arg+='?'+'?';}while(--n);
  1131.     if (!sMode) seat='X';
  1132.     arg += deals+seat;
  1133.     i=0; n=20;
  1134.     do {r=DC[i][ri]; if (r!='X') {s=DC[i][su]; if (!(r=='?'&&s=='?')) arg += r+s;} i++;}while(--n);
  1135.     res=PokerPlugin.getResult(arg);
  1136.     if (res[0]=='e' || res[0]=='x')
  1137.     {
  1138.         fadeMessage(res.substring(1,res.length)); resetResults(); op=0.5; count=0; times=0; error=true;
  1139.         if (res[0]=='x') {reset(2);}
  1140.         dealButtonUp(street); burnFoldLabels(op); street=prevStr=never;
  1141.     }
  1142.     else
  1143.     {
  1144.         stats=res.split(","); n=playercount-1;
  1145.         do{RT[n].innerHTML=stats[n];}while(n--);
  1146.         res=PokerPlugin.getResult('q');
  1147.         if (res[0]=='0' || res[0]=='x')
  1148.         {
  1149.             fadeMessage(res.substring(1,res.length));
  1150.             times=0; count=0; street=prevStr=never;
  1151.         }
  1152.         else if (sMode || (pMode && prevStr!=street) || (pMode==false && ++count>=times))
  1153.         {
  1154.             if (sMode) fadeMessage(sName+stats[playercount]);
  1155.             else { if (pMode) fadeMessage(HT[street]); else fadeMessage(res); }
  1156.             times=Math.floor(Math.random()*4)+4; count=0;
  1157.         }
  1158.         prevStr=street; burnFoldLabels(op);
  1159.     }
  1160.     curShad(); unFoldAndUnBurn(); document.getElementById('kbdInputArea').value=" "; fadeStats=true;
  1161. }
  1162.  
  1163. function purchase()
  1164. {
  1165.     if (widget)
  1166.     {
  1167.         if (runMode == 'r' || (purch && runMode != 't'))
  1168.         {
  1169.             widget.openURL('http://www.floptech.com/misc/feedback.html?p=FlopCruncher1.3');
  1170.             changeImages('purchaseButtonImage', 'Images/back/pb_thanks.png');
  1171.             times=0; runMode='t';
  1172.         }
  1173.         else if (runMode == 't')
  1174.         {
  1175.             changeImages('purchaseButtonImage', 'Images/back/pb_thanks.png');
  1176.         }
  1177.         else
  1178.         {
  1179.             var absolutePath=document.URL, splitPath=absolutePath.split("/"), myName =splitPath[splitPath.length - 1];
  1180.             var regPath=absolutePath.substring(0, (absolutePath.length - myName.length)) + "FlopTechReg.app";
  1181.             widget.openURL(regPath);
  1182.             changeImages('purchaseButtonImage', 'Images/back/pb_feedback.png'); purch=true;
  1183.         }
  1184.     }
  1185. }
  1186.  
  1187. function animate(a)
  1188. {
  1189.     var time=(new Date).getTime(), t=l3(time-a.st,0,a.dur);
  1190.     if (t>=a.dur) {clearInterval(a.tmr); a.tmr=null; a.now=a.to;}
  1191.     else {var e=0.5-(0.5*Math.cos(npi*t/a.dur)); a.now=nxFl(a.from,a.to,e);}
  1192.     a.first.style.opacity=a.now;
  1193. }
  1194.  
  1195. function l3 (a,b,c) {return a<b?b:(a>c?c:a);}
  1196. function nxFl(f,t,e) {return f+(t-f)*e;}
  1197. function changeImages(x,i) {if (foc){var y=document.images[x];y.src=i;}}
  1198.